package com.ruoyi.carrepair.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.carrepair.domain.QxMxWeixiu;
import com.ruoyi.carrepair.service.IQxMxWeixiuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维修明细Controller
 * 
 * @author ruoyi
 * @date 2024-11-19
 */
@RestController
@RequestMapping("/carrepair/weixiumx")
public class QxMxWeixiuController extends BaseController
{
    @Autowired
    private IQxMxWeixiuService qxMxWeixiuService;

    /**
     * 查询维修明细列表
     */
    @PreAuthorize("@ss.hasPermi('carrepair:weixiumx:list')")
    @GetMapping("/list")
    public TableDataInfo list(QxMxWeixiu qxMxWeixiu)
    {
        startPage();
        List<QxMxWeixiu> list = qxMxWeixiuService.selectQxMxWeixiuList(qxMxWeixiu);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('carrepair:weixiumx:list')")
    @GetMapping("/listNoPage")
    public List<QxMxWeixiu> listNoPage(QxMxWeixiu qxMxWeixiu)
    {
        List<QxMxWeixiu> list = qxMxWeixiuService.selectQxMxWeixiuList(qxMxWeixiu);
        return list;
    }

    /**
     * 导出维修明细列表
     */
    @PreAuthorize("@ss.hasPermi('carrepair:weixiumx:export')")
    @Log(title = "维修明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QxMxWeixiu qxMxWeixiu)
    {
        List<QxMxWeixiu> list = qxMxWeixiuService.selectQxMxWeixiuList(qxMxWeixiu);
        ExcelUtil<QxMxWeixiu> util = new ExcelUtil<QxMxWeixiu>(QxMxWeixiu.class);
        util.exportExcel(response, list, "维修明细数据");
    }

    /**
     * 获取维修明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('carrepair:weixiumx:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(qxMxWeixiuService.selectQxMxWeixiuById(id));
    }

    /**
     * 新增维修明细
     */
    @PreAuthorize("@ss.hasPermi('carrepair:weixiumx:add')")
    @Log(title = "维修明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QxMxWeixiu qxMxWeixiu)
    {
        return toAjax(qxMxWeixiuService.insertQxMxWeixiu(qxMxWeixiu));
    }

    /**
     * 修改维修明细
     */
    @PreAuthorize("@ss.hasPermi('carrepair:weixiumx:edit')")
    @Log(title = "维修明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QxMxWeixiu qxMxWeixiu)
    {
        return toAjax(qxMxWeixiuService.updateQxMxWeixiu(qxMxWeixiu));
    }

    /**
     * 删除维修明细
     */
    @PreAuthorize("@ss.hasPermi('carrepair:weixiumx:remove')")
    @Log(title = "维修明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(qxMxWeixiuService.deleteQxMxWeixiuByIds(ids));
    }
}
